package com.wh.controller.initial;

import com.wh.pojo.Supplier;
import com.wh.service.initial.SupplierService;
import com.wh.vo.PageResult;
import com.wh.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/supplier/")
public class SupplierController {

    @Autowired
    private SupplierService supplierService;

    @GetMapping("list")
    public SysResult getSupplierList(PageResult pageResult){
        pageResult = supplierService.getSupplierList(pageResult);
        return SysResult.success(pageResult);
    }

    @PostMapping("addSupplier")
    public SysResult addSupplier(@RequestBody Supplier supplier){
        supplierService.addSupplier(supplier);
        return SysResult.success();
    }

    @PutMapping("updataSupplier")
    public SysResult updataSupplier(@RequestBody Supplier supplier){
        supplierService.updataSupplier(supplier);
        return SysResult.success();
    }

    @DeleteMapping("delete/{name}")
    public SysResult deleteSupplier(@PathVariable String name){
        supplierService.deleteSupplier(name);
        return SysResult.success();
    }
}
